import React, { Component } from 'react'
import store from '../store'
import {add, request} from '../store/actions'

export default class MyComp extends Component {
  componentDidMount() {
    store.subscribe(() => {
      this.setState({})
    })
  }

  addHandler = () => {
    store.dispatch(add())
  }

  requsetHandler = () => {
    store.dispatch(request())
  }
  render() {
    let {count} = store.getState()
    return (
      <div>
        <h2>{count}</h2>
        <button onClick={this.addHandler}>add</button>
        <h2>{1}</h2>
        <button onClick={this.requsetHandler}>request</button>
      </div>
    )
  }
}
